﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using DTO;


namespace DAO
{
    public class ChiTietPhieuNhapSachDAO : AbstractDAO
    {
        public List<ChiTietPhieuNhapSachDTO> GetAll()
        {
            OleDbConnection connection = Open();
            string sql = "SELECT * FROM ChiTietPhieuNhap";
            OleDbCommand command = new OleDbCommand(sql, connection);
            OleDbDataReader reader = command.ExecuteReader();
            List<ChiTietPhieuNhapSachDTO> dsChiTietPhieuNhap = new List<ChiTietPhieuNhapSachDTO>();
            ChiTietPhieuNhapSachDTO s;
            while (reader.Read())
            {
                s = new ChiTietPhieuNhapSachDTO();
                s.MaChiTietPhieuNhap = reader.GetInt32(0);
                s.MaSach = reader.GetInt32(1);
                s.SoLuongNhap = reader.GetInt32(2);
                s.MaPhieuNhap = reader.GetInt32(3);
                s.TinhTrang = reader.GetBoolean(4);
                dsChiTietPhieuNhap.Add(s);
            }
            Close(connection);
            return dsChiTietPhieuNhap;
        }
    }
}
